package com.ruoyi.collection.process;

import com.alibaba.fastjson.JSON;
import com.ruoyi.bizsys.utils.BizConstants;
import com.ruoyi.collection.domain.ApiParameter;
import com.ruoyi.collection.domain.SendSmsReq;
import com.ruoyi.collection.process.api.CollectionProcess;
import com.ruoyi.sms.domain.SmsSendData;
import com.ruoyi.sms.service.ISmsService;
import com.ruoyi.util.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 短信发送
 * @author Victor
 *
 */
@Slf4j
@Service("SendSms")
public class SendSmsPorcessor implements CollectionProcess {

	@Autowired
	private ISmsService smsService;

	@Override
	public Object process(ApiParameter req) throws Exception {

		log.info("发送短信开始");

		SendSmsReq reqBody = JSON.parseObject(req.getBody().toString(), SendSmsReq.class);
		SmsSendData smsData = SmsSendData.builder().noticeType(Constants.SMS_NOTICE_TYPE_COLLECT).smsType(reqBody.getSmsType())
				.countryCode(reqBody.getCountryCode()).phoneNumber(reqBody.getPhoneNumber()).content(reqBody.getContent())
				.fromWhere("Collection")
				.build();

		smsService.sendSms(smsData);

		log.info("发送短信结束");
		return null;
	}


}
